package com.liqing.movecomment.controller;

import com.github.pagehelper.PageInfo;
import com.liqing.movecomment.entity.Move;
import com.liqing.movecomment.service.MoveService;
import com.liqing.movecomment.vo.MoveAddVo;
import com.liqing.movecomment.vo.MoveVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
/**
 * (Move)表控制层
 *
 * @author makejava
 * @since 2023-05-08 02:16:16
 */
import com.liqing.movecomment.annotation.ResponseResult;

import java.util.List;

@ResponseResult
@Api(tags = "move√")
@RequestMapping("move")
public class MoveController {
    /**
     * 服务对象
     */
    @Resource
    private MoveService moveService;



    @GetMapping("hot")
    public PageInfo<MoveVo> hot(Integer page, Integer size){
        return this.moveService.hot( page, size);
    }

    /**
     * 分页查询
     *
     * @param page 页码
     * @param size 页长
     * @return 查询结果
     */
    @GetMapping
    @ApiOperation("keyword 关键词模糊查询。可传可不穿")
    public PageInfo<MoveVo> queryAll(Integer page, Integer size, String keyWord,Integer tag) {
        return this.moveService.queryAll(page, size, keyWord,tag);
    }

    @GetMapping("list")
    public List<Move> list(){
        return this.moveService.list();
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */

    @GetMapping("{id}")
    public MoveVo queryById(@PathVariable("id") Integer id) {
        return this.moveService.queryById(id);
    }

    /**
     * 新增数据
     *
     * @p
     * @return 新增结果
     */
    @PostMapping
    public Move add(@RequestBody MoveAddVo moveAddVo) {
        return this.moveService.insert(moveAddVo);
    }

    /**
     * 编辑数据
     *
     * @param move 实体
     * @return 编辑结果
     */
    @PutMapping
    public Move edit(Move move) {
        return this.moveService.update(move);
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping
    public Boolean deleteById(Integer id) {
        return this.moveService.deleteById(id);
    }

}

